require "rexml/document"
include REXML

def check compleTitle,doc
	r = false
	doc.elements.each('comics/comic'){ |comic|	
		rt = false
		rv = false
		ri = false	
		comic.elements.each('titles/title'){|title|
			rt = (rt or (compleTitle =~/#{title.text}/ ))
		}
		next unless rt
		versions = comic.elements.collect('versions/version'){|version|
			rv = (rv or (compleTitle =~ /#{version.text}/))
		}
		(rv = true) if (versions.length==0)
		next unless rv
		indexs = comic.elements.collect('indexs/index'){|index|
			ri = (ri or (compleTitle =~ /#{index.text}/))
			index.text= (1+ index.text.to_i).to_s if ri
		}
		(ri = true) if (indexs.length == 0)
		rc = (rt and rv and ri)
		r = (r or rc)
	} 
	r
end

